package com.yangjian.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.yangjian.bean.OrderDetail;
import com.yangjian.dao.OrderDetailDao;
import com.yangjian.service.OrderDetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Transactional
@Service
public class OrderDetailServiceImpl implements OrderDetailService {


    @Autowired
    private OrderDetailDao dao;

    /**
     * 添加订单详情
     *
     * @param orderDetail
     * @return
     */
    @Override
    public int add(OrderDetail orderDetail) {
        int row = dao.insert(orderDetail);
        return row;
    }

    /**
     * 根据订单id查询订单详情
     *
     * @param Oid
     * @return
     */
    @Override
    public List<OrderDetail> findByOrderId(Long Oid) {

        LambdaQueryWrapper<OrderDetail> lqw = new LambdaQueryWrapper<>();
        lqw.eq(OrderDetail::getOrderId,Oid);
        List<OrderDetail> orderDetails = dao.selectList(lqw);
        return orderDetails;
    }


}
